package com.tanhua.controller;

import com.tanhua.service.BaiduService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
@Slf4j
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody Map map) {
        Double longitude = Double.valueOf(map.get("longitude").toString());
        Double latitude = Double.valueOf(map.get("latitude").toString());
        String addrStr = map.get("addrStr").toString();
        baiduService.updateLocation(longitude, latitude, addrStr);
        log.info("updateLocation"+map+"---"+ System.currentTimeMillis());
        return ResponseEntity.ok(null);
    }
}